Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@drovp/types

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@drovp/types

Drovp plugin API definitions

  • 3.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@drovp/types

This package contains type definitions for Drovp plugin API (https://github.com/drovp/drovp).

Installation

npm install --save-dev @drovp/types

Documentation

The documentation is at drovp.app/docs/typing.

Quick example

Types are intended to be imported in:

main.ts (plugin)

import {Plugin, PayloadData, makeOptionsSchema, makeAcceptsFlags} from '@drovp/types';

type Options = {
	bulkItems: boolean;
	allowFiles: boolean;
	fileTypes: string[];
};

const schema = makeOptionsSchema<Options>()([
	{name: 'bulkItems', type: 'boolean'},
	{name: 'allowFiles', type: 'boolean'},
	{
		name: 'fileTypes',
		type: 'select',
		default: [],
		options: ['jpg', 'png', 'gif'],
		isHidden: (value, options) => options.allowFiles,
	},
]);
const accepts = makeAcceptsFlags<Options>()({
	files: (item, options) => options.allowFiles && options.fileTypes.includes(item.type),
});

export type Payload = PayloadData<Options, typeof config>;

// Omit if no dependencies
export interface Dependencies {
	ffmpeg: string;
}

export default (plugin: Plugin) => {
	plugin.registerProcessor<Payload>('foo', {
		main: 'dist/processor.js',
		dependencies: ['@drovp/ffmpeg:ffmpeg'],
		accepts: accepts,
		options: schema,
		bulkItems: (items, options) => options.bulkItems,
	});
};

processor.ts

import type {ProcessorUtils} from '@drovp/types';
import type {Payload, Dependencies} from './';

export default async (payload: Payload, utils: ProcessorUtils<Dependencies>) => {
	console.log(payload); // ItemFile(s), profile options, and extra data if any
	console.log(utils.dependencies.ffmpeg); // path to ffmpeg binary
};

Keywords

FAQs

Package last updated on 11 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc